﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace ECommerce.DAO.SQL.Personas
{
    public static class Cliente
    {
        public static ECommerce.Model.Personas.Cliente GetClienteById(Int32 Id)
        {
            ECommerce.Model.Personas.Cliente Cliente = new ECommerce.Model.Personas.Cliente();
            DataTable dt = new DataTable();
            using (SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Repuestos"].ConnectionString))
            {
                using (SqlCommand sqlComm = new SqlCommand("GetClienteById"))
                {
                    sqlComm.CommandType = CommandType.StoredProcedure;
                    SqlParameter param = new SqlParameter();
                    param.SqlDbType = SqlDbType.BigInt;
                    param.Value = Id;
                    param.ParameterName = "@Id";
                    sqlComm.Parameters.Add(param);

                    sqlComm.Connection = sqlConn;
                    sqlConn.Open();
                    using (SqlDataReader dr = sqlComm.ExecuteReader())
                    {
                        dt.Load(dr);
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        Cliente.Load(dr);
                    }
                    sqlConn.Close();
                }
            }
            return Cliente;
        }

        public static int SetCliente(ECommerce.Model.Personas.Cliente cliente)
        {
            throw new NotImplementedException();
        }
    }
}
